package com.teensoft.base.startup.spring;

import javax.servlet.ServletContext;

import org.springframework.web.context.ContextLoader;

import com.teensoft.base.locator.Locator;
import com.teensoft.base.startup.IHandler;

public class SpringHandler implements IHandler {

	private ContextLoader loader = null;
	
	public void invokeInit(ServletContext context){
		loader = new ContextLoader();
		loader.initWebApplicationContext(context);
		Locator.setApplicationContext(ContextLoader.getCurrentWebApplicationContext());
	}
	
	public void invokeDestory(ServletContext context){
		if(loader != null)
			loader.closeWebApplicationContext(context);
		Locator.setApplicationContext(null);
	}
	
	
}
